package com.google.code.maven2.plugins.hotswap.support;

import java.io.File;
import java.io.FileFilter;

/**
 * To use, call <code>ClassFileFilter.CLAZZ</code>
 *
 * @author Mike Nereson
 * @since 1.0
 */
public class ClassFileFilter
        implements FileFilter
{
    /**
     * The file name suffix of a java class file.
     */
    private final String CLASS_FILE_NAME_SUFFIX = ".class";

    /**
     * Singleton instance of class filter.
     */
    public static final FileFilter CLAZZ = new ClassFileFilter();

    /**
     * Singleton instance of class filter.
     */
    public static final FileFilter INSTANCE = CLAZZ;

    /**
     * Restrictive consructor.
     */
    protected ClassFileFilter()
    {
    }

    /**
     * Tests whether or not the specified abstract pathname should be included in a pathname list.
     *
     * @param pathname The abstract pathname to be tested
     * @return <code>true</code> if the file is determined to be a class file
     */
    public boolean accept(File file)
    {
        return !file.isDirectory() && file.getName().endsWith(CLASS_FILE_NAME_SUFFIX);
    }
}
